/* Copyright (c) 2004-2008, Andriy Nikolov
 * All rights reserved.
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package org.processmining.email;

import javax.swing.table.*;

/**
 * <p>The table model class to show the list of event types in the table.
 * It is used when determining the process log building options.</p>
 *
 * @author Andriy Nikolov
 * @version 1.0
 */
public class EventTableModel
    extends AbstractTableModel {
  ProcessLog processLog;

  String[] columnNames = {
    "Standard type",
    "Alias name"
  };

  public EventTableModel() {

  }

  public EventTableModel(ProcessLog log) {
    processLog = log;
  }

  public void setProcessLog(ProcessLog log) {
    processLog = log;
  }

  public ProcessLog getProcessLogLog() {
    return processLog;
  }

  public int getRowCount() {
    return processLog.getEventTypesList().size();
  }

  public int getColumnCount() {
    return columnNames.length;
  }

  public String getColumnName(int col) {
    return columnNames[col];
  }

  public Class getColumnClass(int c) {
    return new String().getClass();
  }

  public boolean isCellEditable(int row, int col) {
    if (col==1)
      return true;
    return false;
  }

  public Object getValueAt(int row, int col) {
    ProcessEventType tmp;
    tmp = (ProcessEventType)processLog.getEventTypesList().get(row);
    switch (col) {
      case 0:
        return tmp.getStandardName();
      case 1:
        return tmp.getAliasName();
    }
    return new String();
  }

  public void setValueAt(Object value, int row, int col) {
    Boolean active;
    ProcessEventType tmp;
    tmp = (ProcessEventType)processLog.getEventTypesList().get(row);
    if (col==1) {
      tmp.setAliasName((String)value);
    }
  }

}
